<?php

session_start();

require_once("includes/connect.php");
require_once("includes/function.php");

$id = $_REQUEST["id"];
$panngan2 = $_REQUEST["panngan2"];
$panngan3 = $_REQUEST["panngan3"];

$month_year = $_REQUEST["month_year"];
$salary = $_REQUEST["salary"];
$running = $_REQUEST["running"];
$emoluments = $_REQUEST["emoluments"];
$tok_beuk = $_REQUEST["tok_beuk"];
$medical_fee = $_REQUEST["medical_fee"];
$education = $_REQUEST["education"];
$extra = $_REQUEST["extra"];
$rent_home = $_REQUEST["rent_home"];
$other1 = $_REQUEST["other1"];
$tax = $_REQUEST["tax"];
$tax1= $_REQUEST["tax1"];
$cremation1 = $_REQUEST["cremation1"];
$welfare = $_REQUEST["welfare"];
$cooperative = $_REQUEST["cooperative"];
$loan = $_REQUEST["loan"];
$bongkum = $_REQUEST["bongkum"];
$ghb = $_REQUEST["ghb"];
$aia = $_REQUEST["aia"];
$cremation2 = $_REQUEST["cremation2"];
$other2 = $_REQUEST["other2"];
$total1 = $_REQUEST["total1"];
$total2 = $_REQUEST["total2"];

//$salary_id = $_REQUEST["salary_id"];

$budget_year = $_REQUEST["budget_year"];

$task = $_REQUEST["task"];

$db = new myDBS;
$db->selectDB("account");

switch ($task) {
    case "new":
        $sql = "INSERT INTO tbl_init (lvl1_id,
			card_id ,	panngan2_id ,	panngan3_id ,	month_year ,	salary ,	budget_year , emoluments ,	tok_beuk ,	medical_fee ,	education ,	extra ,	rent_home ,	other1 ,	tax , tax1,	cremation1 ,	welfare ,
			cooperative ,	loan ,	bongkum ,	ghb ,	aia ,	cremation2 ,	other2 ,	total1 ,	total2
			)
			VALUES ('" . $_SESSION["lvl1_id"] . "',
			 '$id',  '$panngan2',  '$panngan3',  '$month_year',  '$salary',  '$budget_year',  '$emoluments',  '$tok_beuk',  '$medical_fee',  '$education',  '$extra',  '$rent_home',  '$other1',  '$tax', '$tax1',  '$cremation1',  '$welfare',  '$cooperative',  '$loan',  '$bongkum',  '$ghb',  '$aia',  '$cremation2',  '$other2',  '$total1',  '$total2'
			)
			";

        $db->insData($sql);
        echo "budget_year=$budget_year&panngan2_id=$panngan2&panngan3_id=$panngan3&month_year=$month_year";
        break;
    case "edit":
        $sql = "UPDATE tbl_init SET 
                        emoluments = '$emoluments' , tok_beuk = '$tok_beuk' ,	medical_fee ='$medical_fee',
                        education = '$education',	extra = '$extra',	rent_home = '$rent_home',	other1 = '$other1',	tax = '$tax',tax1 = '$tax1',	cremation1 = '$cremation1',	welfare = '$welfare', cooperative = '$cooperative',	loan = '$loan',	bongkum ='$bongkum' ,	ghb = '$ghb',	aia = '$aia',	cremation2 = '$cremation2',	other2 = '$other2',	total1 = '$total1',	total2 = '$total2'
                        WHERE  card_id = '$id'
                        AND panngan2_id = '$panngan2'
                        AND panngan3_id = '$panngan3'
                        AND month_year = '$month_year'
                        AND budget_year = '$budget_year'
				";
        $db->runSQL($sql);
        echo "budget_year=$budget_year&panngan2_id=$panngan2&panngan3_id=$panngan3&month_year=$month_year";
        break;
}
?>
